<?php

/*
Edit Item (admin_edit_item.php)
*/

$page_title = "Edit Item";
$rank_check = 7;
include "../header.inc.php";

$game=$_GET['game'];
$act=$_GET['act'];

print "$openHTML";

if (!$act)
{
	
ECHO <<<END

<FORM ACTION="admin_edit_item.php?game=$game&act=edit" METHOD=POST> <CENTER><TABLE BGCOLOR="$tableOutline"
CELLSPACING=1 CELLPADDING=0 WIDTH=520> <TR BGCOLOR="$topAndBottomBG"> <TD COLSPAN=2 HEIGHT=50>
<CENTER><FONT SIZE="+2" COLOR="$topAndBottomText">--Edit Item--</FONT></CENTER> </TD> </TR>
<TR BGCOLOR="$maincellColor"> <TD WIDTH=128 HEIGHT=40> <P>Edit Item</P> </TD> <TD
HEIGHT=40> <P><FONT SIZE="-1">&nbsp; <input type=text name=edit_item></FONT></P> </TD> </TR> <TR> <TD
COLSPAN=2 HEIGHT=30 BGCOLOR="$topAndBottomBG"> <CENTER><FONT SIZE="-1" COLOR="$topAndBottomText"><I><INPUT
TYPE=submit NAME=Submit VALUE="Edit Item!!"></I></FONT></CENTER> </TD> </TR>
</TABLE> </CENTER> </FORM>

END;

}

if ($act == "edit")
{

$edit_item = $_POST['edit_item'];

$findItem = fetch("SELECT * FROM items2 WHERE game = '$game' AND item_name = '$edit_item'");
$findBattle = fetch("SELECT * FROM battle_items2 WHERE game = '$game' AND item_id = '$findItem[id]'");
$findShop = fetch("SELECT * FROM shop_items2 WHERE game = '$game' AND item_name = '$findItem[item_name]'");

$x = 0;

$findShops = mysql_query("SELECT * FROM official_shops2 WHERE game = '$game'");
while ($getShops = mysql_fetch_array($findShops))
{
	if ($findShop[sell_in] == $getShops[id])
	{
		$selectShop[$x] = " SELECTED";
	}
	
	$shopList .= "<option value=$getShops[id]$selectShop[$x]>$getShops[shop_name]";
	$x++;
}

if ($findItem[retired] == 1) { $retireCheck = " CHECKED"; }
if ($findShop[id]) { $shopCheck = " CHECKED"; }
if ($findBattle[id]) { $battleCheck = " CHECKED"; }

if ($findItem[item_rarity] == 1) { $selectR1 = " SELECTED"; }
if ($findItem[item_rarity] == 2) { $selectR2 = " SELECTED"; }
if ($findItem[item_rarity] == 3) { $selectR3 = " SELECTED"; }
if ($findItem[item_rarity] == 4) { $selectR4 = " SELECTED"; }
if ($findItem[item_rarity] == 5) { $selectR5 = " SELECTED"; }
if ($findItem[item_rarity] == 6) { $selectR6 = " SELECTED"; }
if ($findItem[item_rarity] == 7) { $selectR7 = " SELECTED"; }

if ($findItem[item_type] == "food") { $selectIT1 = " SELECTED"; }
if ($findItem[item_type] == "health_potion") { $selectIT2 = " SELECTED"; }
if ($findItem[item_type] == "battle_item") { $selectIT3 = " SELECTED"; }
if ($findItem[item_type] == "level_inc") { $selectIT4 = " SELECTED"; }
if ($findItem[item_type] == "strength_inc") { $selectIT5 = " SELECTED"; }
if ($findItem[item_type] == "speed_inc") { $selectIT6 = " SELECTED"; }
if ($findItem[item_type] == "intel_inc") { $selectIT7 = " SELECTED"; }
if ($findItem[item_type] == "toy") { $selectIT8 = " SELECTED"; }
if ($findItem[item_type] == "defence_inc") { $selectIT9 = " SELECTED"; }
if ($findItem[item_type] == "pet_look") { $selectIT10 = " SELECTED"; }



if ($findBattle[battle_type] == "attack") { $selectBT1 = " SELECTED"; }
if ($findBattle[battle_type] == "defence") { $selectBT2 = " SELECTED"; }
if ($findBattle[battle_type] == "lower_acc") { $selectBT3 = " SELECTED"; }
if ($findBattle[battle_type] == "raise_acc") { $selectBT4 = " SELECTED"; }
if ($findBattle[battle_type] == "double_damage") { $selectBT5 = " SELECTED"; }

$itemTypes = "
<OPTION value=food$selectIT1>Food</option>
<OPTION value=health_potion$selectIT2>Health Potion</option>
<OPTION value=battle_item$selectIT3>Battle Item</option>
<OPTION value=level_inc$selectIT4>Raise Level</option>
<OPTION value=strength_inc$selectIT5>Raise Strength</option>
<OPTION value=speed_inc$selectIT6>Raise Speed</option>
<OPTION value=intel_inc$selectIT7>Book</option>
<OPTION value=toy$selectIT8>Toy</option>
<OPTION value=defence_inc$selectIT9>Raise Defence</option>
<OPTION value=pet_look$selectIT10>Change Pet Look</option>
";

$battleTypes = "
<OPTION value=attack$selectBT1>Attack</option>
<OPTION value=defence$selectBT2>Defence</option>
<OPTION value=lower_acc$selectBT3>Lower Accuracy</option>
<OPTION value=raise_acc$selectBT4>Raise Accuracy</option>
<OPTION value=double_damage$selectBT5>Double Damage</option>
";

ECHO <<<END

<FORM ACTION="admin_edit_item.pro.php?game=$game&edit=$findItem[id]" enctype="multipart/form-data" METHOD=POST>


<style type="text/css">.header {font-family:Charcoal; font-size:10px; color:#$topAndBottomBG; border-style:dotted; border-width:3px; background-color:transparent; width:350px; </STYLE>

<center><p class=header align=center><img src=$base_url/images/user_images/opg_$game/items/item_$findItem[id].gif><br>$findItem[item_name]</center>

   <P align=center><TABLE BGCOLOR="$tableOutline" CELLSPACING=1 width=450>
      <TR BGCOLOR="$topAndBottomBG" height=25 width=100%>
         <TD COLSPAN=2 HEIGHT=45>
            <CENTER><FONT SIZE="+2" COLOR="$topAndBottomText"><B>--General
            Info--</B></FONT></CENTER>
         </TD>
      </TR>
      <TR BGCOLOR="$maincellColor" height=25 width=100%>
         <TD>
            <P>Item Name:</P>
         </TD>
         <TD>
            <P><INPUT TYPE=text NAME="item_name" VALUE="$findItem[item_name]" SIZE=40 maxsize=32></P>
         </TD>
      </TR>
      <TR BGCOLOR="$middleBG" height=25 width=100%>
         <TD>
            <P>Image:</P>
         </TD>
         <TD>
            <P><input type=file name=itemImage><br><font size=-1>(only use this if your changing the image!)</font></P>
         </TD>
      </TR>
      <TR BGCOLOR="$maincellColor" height=25 width=100%>
         <TD>
            <P>Description:</P>
         </TD>
         <TD>
            <P><INPUT TYPE=text NAME="item_desc" VALUE="$findItem[item_desc]" SIZE=40></P>
         </TD>
      </TR>
      <TR BGCOLOR="$middleBG" height=25 width=100%>
         <TD>
            <P>Rarity:</P>
         </TD>
         <TD>
            <P><select name=rarity><option>Choose a Rarity
            <option value=1$selectR1>Common
            <option value=2$selectR2>Uncommon
            <option value=3$selectR3>Semi Rare
            <option value=4$selectR4>Rare
            <option value=5$selectR5>Super Rare
            <option value=6$selectR6>Ultra Rare
            <option value=7$selectR7>1 of a kind!
            </select>
         </TD>
      </TR>
      <TR BGCOLOR="$maincellColor" height=25 width=100%>
         <TD>
            <P>Magic Number:</P>
         </TD>
         <TD>
            <P><INPUT TYPE=text NAME="magic_number" VALUE="$findItem[magic_num]" SIZE=20>
            <a href=help.php?game=$game&help=magic_number>HUH??</a></P>
         </TD>
      </TR>
      <TR BGCOLOR="$middleBG" height=25 width=100%>
         <TD>
            <P>Value:</P>
         </TD>
         <TD>
            <P><INPUT TYPE=text NAME=value VALUE="$findItem[item_value]" SIZE=20> (Approx.
            value in $pointsVar)</P>
         </TD>
      </TR>
      <TR BGCOLOR="$maincellColor" height=25 width=100%>
         <TD>
            <P>Item Type:</P>
         </TD>
         <TD>
            <P><SELECT NAME="item_type">
               <OPTION>-----
				$itemTypes
            </SELECT><a href=help.php?game=$game&help=item_types>HUH??</a></P>
         </TD>
      </TR>
      <TR BGCOLOR="$middleBG" height=25 width=100%>
         <TD>
            <P>Parts</P>
         </TD>
         <TD>
            <INPUT TYPE=text NAME="item_parts" VALUE="$findItem[parts]" SIZE=20></P>
         </TD>
      </TR>
      <TR BGCOLOR="$maincellColor" height=25 width=100%>
         <TD>
            <P>Retired:</P>
         </TD>
         <TD>
            <P><INPUT TYPE=checkbox NAME=retired VALUE=1$retireCheck>
            (Checked = Retired)</P>
         </TD>
      </TR>
      <TR BGCOLOR="$middleBG" height=25 width=100%>
         <TD>
            <P>Sell In Shops?</P>
         </TD>
         <TD>
            <P><INPUT TYPE=checkbox NAME="sell_in_shops" VALUE=1$shopCheck>
            (Checked = Yes)</P>
         </TD>
      </TR>
            <TR BGCOLOR="$maincellColor" height=25 width=100%>
         <TD>
            <P>Battle item?</P>
         </TD>
         <TD>
            <P><INPUT TYPE=checkbox NAME="battle_item" VALUE=1$battleCheck>
            (Checked = Yes)</P>
         </TD>
      </TR>
      <TR BGCOLOR="$topAndBottomBG" height=25 width=100%>
         <TD COLSPAN=2 HEIGHT=45>
            <CENTER><FONT SIZE="+2" COLOR="$topAndBottomText"><B>--Shop
            Info--</B><BR>
            </FONT><FONT SIZE="-1" COLOR="$topAndBottomText">(Fill out this
            only if "Sell In Shops?" above is
            checked)</FONT></CENTER>
         </TD>
      </TR>
      <TR BGCOLOR="$maincellColor" height=25 width=100%>
         <TD>
            <P>Cost:</P>
         </TD>
         <TD>
            <P><INPUT TYPE=text NAME="item_cost" VALUE="$findShop[sell_for]" SIZE=20>
            (In $pointsVar)</P>
         </TD>
      </TR>
      <TR BGCOLOR="$middleBG" height=25 width=100%>
         <TD>
            <P>Max Stock:</P>
         </TD>
         <TD>
            <P><INPUT TYPE=text NAME="max_stock" VALUE="$findShop[max_stock]" SIZE=20></P>
         </TD>
      </TR>
      <TR BGCOLOR="$maincellColor" height=25 width=100%>
         <TD>
            <P>Sell In:</P>
         </TD>
         <TD>
            <P><SELECT NAME="sell_in">
               <OPTION>Choose a Shop
               $shopList
            </SELECT></P>
         </TD>
      </TR>
      <TR BGCOLOR="$topAndBottomBG" height=25 width=100%>
         <TD COLSPAN=2 HEIGHT=45>
            <CENTER><FONT SIZE="+2" COLOR="$topAndBottomText"><B>--Battle
            Info--</B><BR>
            </FONT><FONT SIZE="-1" COLOR="$topAndBottomText">(Fill out this
            only if "Battle Item?" above is
            checked)</FONT></CENTER>
         </TD>
      </TR>
      <TR BGCOLOR="$maincellColor" height=25 width=100%>
         <TD>
            <P>Battle Type:</P>
         </TD>
         <TD>
            <P><SELECT NAME="battle_type">
               <OPTION>-----
				$battleTypes
            </SELECT><a href=help.php?game=$game&help=battle_types>HUH??</a></P>
         </TD>
      </TR>
      <TR BGCOLOR="$maincellColor" height=25 width=100%>
         <TD>
            <P>Uses:</P>
         </TD>
         <TD>
            <P><INPUT TYPE=text NAME="battle_uses" VALUE="$findBattle[uses]" SIZE=20> <a href=help.php?game=$game&help=battle_uses>TIPS!</a></P>
         </TD>
      </TR>
      <TR BGCOLOR="$topAndBottomBG" height=25 width=100%>
         <TD COLSPAN=2>
            <CENTER><INPUT TYPE=submit NAME=Submit VALUE="Edit Item!"></CENTER>
         </TD>
      </TR>
   </TABLE>

</FORM></P>

END;
}

print "$closeHTML";
?>
